{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from xgboost import XGBClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import roc_auc_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Read in the training and testing sets\n",
    "data_train = pd.read_pickle('./CAD_train_ukb.pkl')\n",
    "data_test = pd.read_pickle('./CAD_test_ukb.pkl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Target variable extraction\n",
    "y_test = data_test['Class']\n",
    "y_train = data_train['Class']\n",
    "\n",
    "# Feature extraction\n",
    "top_snps = data_train.columns[1:-1]\n",
    "X_train = data_train[top_snps].values\n",
    "X_test = data_test[top_snps].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Define the model\n",
    "xgb_model = XGBClassifier(random_state=42)\n",
    "\n",
    "# Fit the model\n",
    "xgb_model.fit(X_train,y_train)\n",
    "\n",
    "# Model prediction\n",
    "y_pred_pro = xgb_model.predict_proba(X_test)[:,1]\n",
    "\n",
    "# Model Evalation\n",
    "test_auc = roc_auc_score(y_score=y_pred_pro, y_true=y_test)\n",
    "print(round(test_auc*100,3))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
